package com.xq.algorithm;

import static com.xq.algorithm.sort.SwapSortAlgorithm.testQuickSort;

/**
 * @author jltxseo
 *         Created by junlintianxia on 2017/07/09.
 */

public class AlgorithmTest {

    public  static void main(String[] args){
//        testBinaryInsertSort();
//        testInsertSort();
//        testshellSort();
//        testSelectSort();
//        testHeadSort();
//        testBubbleSort();
        testQuickSort();
//        testMergeSort();
//        testBinarySearch1(5);
//        String s = "ABCDABD";
//        String s1 = "ababaaaba";
//        int[] next = KMPAlgorithm.getNextArray(s1);
//        printlnAry(next);

//        StringAlgorithm stringAlgorithm = new StringAlgorithm();
//        List<String> stringList = stringAlgorithm.Permutation("abc");
//        for (String str : stringList){
//            System.out.println("str=>"+str);
//        }

//        MathAlgorithm.NumberOf1(12);
//        System.out.println(StringAlgorithm.reverseString("I am a student.   ".toCharArray()));
//        System.out.println(StringAlgorithm.leftRotateString("abcdefg".toCharArray(),2));
//        System.out.println(StringAlgorithm.reverseString3("Let's take LeetCode contest".toCharArray()));
//        boolean isPalidrome = StringAlgorithm.isPalidrome("12321");
//        System.out.println("isPalidrom:"+isPalidrome);
    }

    /**
     * 打印数组
     * @param a
     */
    public static void printlnAry(int[] a){
        if(a == null)return;
        StringBuilder sb = new StringBuilder();

        for (int i=0; i < a.length; i++){
            if(i == 0) sb.append("[");
            sb.append(a[i]);
            if(i != a.length - 1){
                sb.append(",");
            }else {
                sb.append("]");
            }
        }
        System.out.println("a=>"+sb.toString());
    }

}
